/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package radio.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Huu Vinh
 */
@Entity
@Table(name = "AccountDetails", catalog = "Radio_Cabs", schema = "dbo", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"Email"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AccountDetails.findAll", query = "SELECT a FROM AccountDetails a"),
    @NamedQuery(name = "AccountDetails.findByAccId", query = "SELECT a FROM AccountDetails a WHERE a.accId = :accId"),
    @NamedQuery(name = "AccountDetails.findByContactPerson", query = "SELECT a FROM AccountDetails a WHERE a.contactPerson = :contactPerson"),
    @NamedQuery(name = "AccountDetails.findByMobile", query = "SELECT a FROM AccountDetails a WHERE a.mobile = :mobile"),
    @NamedQuery(name = "AccountDetails.findByTelephone", query = "SELECT a FROM AccountDetails a WHERE a.telephone = :telephone"),
    @NamedQuery(name = "AccountDetails.findByAddress", query = "SELECT a FROM AccountDetails a WHERE a.address = :address"),
    @NamedQuery(name = "AccountDetails.findByEmail", query = "SELECT a FROM AccountDetails a WHERE a.email = :email")})
public class AccountDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "AccId", nullable = false)
    private Integer accId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "ContactPerson", nullable = false, length = 50)
    private String contactPerson;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Mobile", nullable = false, length = 50)
    private String mobile;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Telephone", nullable = false, length = 50)
    private String telephone;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "Address", nullable = false, length = 2147483647)
    private String address;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Email", nullable = false, length = 50)
    private String email;
    @JoinColumn(name = "CityId", referencedColumnName = "CityId", nullable = false)
    @ManyToOne(optional = false)
    private City cityId;
    @JoinColumn(name = "AccId", referencedColumnName = "AccId", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Accounts accounts;

    public AccountDetails() {
    }

    public AccountDetails(Integer accId) {
        this.accId = accId;
    }

    public AccountDetails(Integer accId, String contactPerson, String mobile, String telephone, String address, String email) {
        this.accId = accId;
        this.contactPerson = contactPerson;
        this.mobile = mobile;
        this.telephone = telephone;
        this.address = address;
        this.email = email;
    }

    public Integer getAccId() {
        return accId;
    }

    public void setAccId(Integer accId) {
        this.accId = accId;
    }

    public String getContactPerson() {
        return contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public City getCityId() {
        return cityId;
    }

    public void setCityId(City cityId) {
        this.cityId = cityId;
    }

    public Accounts getAccounts() {
        return accounts;
    }

    public void setAccounts(Accounts accounts) {
        this.accounts = accounts;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accId != null ? accId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AccountDetails)) {
            return false;
        }
        AccountDetails other = (AccountDetails) object;
        if ((this.accId == null && other.accId != null) || (this.accId != null && !this.accId.equals(other.accId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "radio.entities.AccountDetails[ accId=" + accId + " ]";
    }
    
}
